package com.heima.controller;


import com.heima.pojo.entity.BusinessType;
import com.heima.pojo.vo.BusinessTypeVo;
import com.heima.service.BusinessService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/api/vm-service/businessType")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @GetMapping
    public List<BusinessTypeVo> searchBusinessType() {
        List<BusinessType> list = businessService.list();
        return list.stream().map(businessType -> {
            BusinessTypeVo businessTypeVo = new BusinessTypeVo();
            BeanUtils.copyProperties(businessType, businessTypeVo);
            return businessTypeVo;
        }).collect(Collectors.toList());
    }
}


